
var ctx=window.daijia.ctx;
var end=window.daijia.end;
var start=window.daijia.start;

$(document).ready(function(){
	
	var newDate = new Date();
	var startDate = new Date();
	startDate.setDate(startDate.getDate()-30);
	var startTimeStr=startDate.getFullYear()+"-"+((startDate.getMonth()+1)>9?(startDate.getMonth()+1):'0' + (startDate.getMonth()+1))+"-"+(startDate.getDate()>9?startDate.getDate():'0' + startDate.getDate());
	var endTimeStr=newDate.getFullYear()+"-"+((newDate.getMonth()+1)>9?(newDate.getMonth()+1):'0' + (newDate.getMonth()+1))+"-"+(newDate.getDate()>9?newDate.getDate():'0' + newDate.getDate());
	$("#startTime").val(start);
	$("#endTime").val(end);
	$("#dateRangeText").text($("#startTime").val()+" 至 "+$("#endTime").val());
	
	//点击选择时间
	$("#dateRangeButton").click(function(){
		var dropdowncalendar=$(this).parent().find(".dropdown-calendar");
		if(dropdowncalendar.is(':hidden')){
			dropdowncalendar.show();
			if(dropdowncalendar.find(".datepicker").length==0){
				$('#dateRangeCalendar').DatePicker({
					flat: true,
					date: [startDate,newDate],
					current: newDate,
					calendars: 3,
					mode: 'range',
					starts: 1,
					onChange: function(formated, dates){
						$("#startTime").val(formated[0]);
						$("#endTime").val(formated[1]);
					}
				});
			}
		}
		else{
			dropdowncalendar.hide();
		}
	});
	
	//点击应用
	$("#applyIt").click(function(){
		$("#SearchForm").submit();
	});
	
	$("#companyId").change(function(){
	  
		   $("#SearchForm").submit();  
	 });

	
});
	

